<% import grails.persistence.Event %>
<%=packageName%>
<!DOCTYPE html>
<html>
	<head>
		<meta name="layout" content="main">
		<g:set var="entityName" value="\${message(code: '${domainClass.propertyName}.label', default: '${className}')}" />
		<title><g:message code="default.list.label" args="[entityName]" /></title>
	</head>
	<body>
		<div class="container-fluid">
			<div class="row">
				<div id="list-${domainClass.propertyName}" class="col-md-12" role="main">
					<fieldset>
						<legend>
							<g:message code="default.list.label" args="[entityName]" />
							<span class="pull-right">
								<g:link class="btn btn-primary btn-sm" action="create">
									<i class="glyphicon glyphicon-plus"></i>
									<g:message code="default.new.label" args="[entityName]" />
								</g:link>
							</span>
						</legend>
						<g:if test="\${flash.message}">
							<div class="message" role="status">\${flash.message}</div>
						</g:if>
						<table class="table table-condensed table-striped">
							<thead>
								<tr>
								<%  excludedProps = Event.allEvents.toList() << 'id' << 'version'
									allowedNames = domainClass.persistentProperties*.name << 'dateCreated' << 'lastUpdated'
									props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) && it.type != null && !Collection.isAssignableFrom(it.type) && (domainClass.constrainedProperties[it.name] ? domainClass.constrainedProperties[it.name].display : true) }
									Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
									props.eachWithIndex { p, i ->
										if (i < 6) {
											if (p.isAssociation()) { %>
									<th><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" /></th>
								<%      } else { %>
									<g:sortableColumn property="${p.name}" title="\${message(code: '${domainClass.propertyName}.${p.name}.label', default: '${p.naturalName}')}" />
								<%  }   }   } %>
									<th>Actions</th>
								</tr>
							</thead>
							<tbody>
							<g:each in="\${${propertyName}List}" status="i" var="${propertyName}">
								<tr class="\${(i % 2) == 0 ? 'even' : 'odd'}">
								<%  props.eachWithIndex { p, i ->
										if (i == 0) { %>
									<td>\${fieldValue(bean: ${propertyName}, field: "${p.name}")}</td>
								<%      } else if (i < 6) {
											if (p.type == Boolean || p.type == boolean) { %>
									<td><g:formatBoolean boolean="\${${propertyName}.${p.name}}" /></td>
								<%          } else if (p.type == Date || p.type == java.sql.Date || p.type == java.sql.Time || p.type == Calendar) { %>
									<td><g:formatDate date="\${${propertyName}.${p.name}}" /></td>
								<%          } else { %>
									<td>\${fieldValue(bean: ${propertyName}, field: "${p.name}")}</td>
								<%  }   }   } %>
									<td>
										<g:link class="btn btn-sm btn-default glyphicon glyphicon-eye-open" action="show" id="\${${propertyName}.id}"></g:link>
										<g:link class="btn btn-sm btn-default glyphicon glyphicon-pencil" action="edit" resource="\${${propertyName}}"></g:link>
										<g:link class="btn btn-sm btn-danger glyphicon glyphicon-trash" onclick="return confirm('\${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" action="delete" resource="\${${propertyName}}"></g:link>
									</td>
								</tr>
							</g:each>
							</tbody>
						</table>
						<div class="pagination">
							<g:paginate total="\${${propertyName}Count ?: 0}" />
						</div>
					</fieldset>
				</div>
			</div>
		</div>
	</body>
</html>
